package ca.ioniq.shared.entity;

// Generated Jan 20, 2011 9:08:49 AM by Hibernate Tools 3.4.0.Beta1

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Item generated by hbm2java
 */
@Entity
@Table(name = "item")
@XmlRootElement(name = "item")
@NamedQueries({
	@NamedQuery(name="getItemsByCategory", query="select i from Item i where i.category.id = :categoryId"),
	@NamedQuery(name="getItemsByBrand", query="select i from Item i where i.brand.id = :brandId"),
	@NamedQuery(name="getItemsByCategoryAndCompany", query="select i from Item i where i.category.id = :categoryId and i.brand.company.id = :companyId")
})
public class Item implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Long id;
	private Brand brand;
	private Category category;
	private String img;
	private String name;
	private String description;
	private Long price;

	public Item() {
	}

	public Item(Brand brand, Category category, String img, String name) {
		this.brand = brand;
		this.category = category;
		this.img = img;
		this.name = name;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	@XmlElement
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
	@JoinColumn(name = "brand_id")
	@XmlElement
	public Brand getBrand() {
		return this.brand;
	}

	public void setBrand(Brand brand) {
		this.brand = brand;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
	@JoinColumn(name = "category_id")
	@XmlElement
	public Category getCategory() {
		return this.category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	@Column(name = "img")
	@XmlElement
	public String getImg() {
		return this.img;
	}

	public void setImg(String img) {
		this.img = img;
	}

	@Column(name = "name")
	@XmlElement
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "description")
	@XmlElement
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "price")
	@XmlElement
	public Long getPrice() {
		return price;
	}

	public void setPrice(Long price) {
		this.price = price;
	}
}
